
export default {

  data() {
    return {
      endTime: '',
      pickerOptionsStart: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000
        }
      },
      pickerOptionsEnd: {
        disabledDate(time) {
          return time.getTime() > Date.now() - 8.64e6
        }
      }
    }
  },

  methods: {
    // 截止日期限制为开始日期之后
    timeStart(date) {
      console.log('----------------------------')
      this.pickerOptionsStart = Object.assign({}, this.pickerOptionsStart)
      const date1 = Date.parse(new Date(date))
      const { startTime, endTime } = this.submitValue
      // 如果截止时间小于开始时间则清空截止时间
      if (startTime && endTime) {
        const sT = new Date(startTime).getTime()
        const eT = new Date(endTime).getTime()
        if (eT < sT) {
          this.submitValue.endTime = ''
        }
      }
      if (this.endTime) {
        console.log('----------------')
        console.log(this.endTime)
        const edTime = this.endTime
        this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, {
          disabledDate(time) {
            return time.getTime() < date1 - 1 * 24 * 60 * 60 * 1000 + 8.64e6 || time.getTime() > edTime
          }
        })
        console.log(this.pickerOptionsEnd)
      } else {
        this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, {
          disabledDate(time) {
            return time.getTime() < date1 - 1 * 24 * 60 * 60 * 1000 + 8.64e6
          }
        })
      }
    },
    timeEnd(date) {
      const { startTime, endTime } = this.submitValue
      // 如果截止时间小于开始时间则清空截止时间
      if (startTime && endTime) {
        const sT = new Date(startTime).getTime()
        const eT = new Date(endTime).getTime()
        if (eT < sT) {
          this.submitValue.endTime = ''
        }
      }
    }

  }

}
